/*
封装storage.js 
以后出去工作，直接复制这个js到项目中即可
*/
import config from "../config"
export default {
    setItem (key, val) {
        let storage = this.getstorage()
        storage[key] = val
        window.localStorage.setItem(config.namespace, JSON.stringify(storage))
    },

    getItem (key) {
        return this.getstorage()[key]
    },

    clearItem (key) {
        // 单独的某些删除
        let stoage = this.getstorage()
        delete stoage[key]
        window.localStorage.setItem(config.namespace, JSON.stringify(storage))
    },

    clearAll () {
        window.localStorage.clear()
    },

    getstorage () {
        return JSON.parse(window.localStorage.getItem(config.namespace) || "{}")
    }
    // 作用域名(作用是区分项目) 
    // count 
}